package com.intellekt.ecert.login.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import com.intellekt.ecert.domain.CatalogoVO;
import com.intellekt.ecert.domain.Constantes;
import com.intellekt.ecert.login.service.LoginService;
import com.opensymphony.xwork2.ActionSupport;
@Results({ @Result(name = "success", location = "login.jsp") })
public class LogoutAction extends ActionSupport implements SessionAware, ServletRequestAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2793675175711260339L;
	private static final Logger log = Logger.getLogger(LogoutAction.class);

	protected Map<String, Object> session;

	@SuppressWarnings("rawtypes")
	private Map request;

	@Autowired
	protected LoginService service;
	private List<CatalogoVO> roles;

	@SuppressWarnings("unused")
	private HttpSession httpSession;

	public String execute() throws Exception {
		if (log.isInfoEnabled()) {
			log.info("execute...");
		}

		session.put(Constantes.USUARIO, null);

		if (log.isDebugEnabled()) {
			log.debug("Adios...");
		}

		return SUCCESS;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	@SuppressWarnings("rawtypes")
	public final Map getRequest() {
		return request;
	}

	public final Map<String, Object> getSession() {
		return session;
	}

	public void setServletRequest(HttpServletRequest request) {
		if (request != null) {
			httpSession = request.getSession();
		}
	}

	public final List<CatalogoVO> getRoles() {
		return roles;
	}

	public final void setRoles(List<CatalogoVO> roles) {
		this.roles = roles;
	}

}
